<?php
/*
 * 作者：*****
 * 内容：教练分组表
 */
namespace App\model;

use Illuminate\Database\Eloquent\Model;
use DB;
class Use_coach extends Model
{
    protected $table='use_coach';
    /*
	 * 作者：*****
	 * 内容：查询各组教练的信息
	 */
    public function selectCoachInfo()
    {
        return $this
            ->select('use_name','use_num','use_sex','use_card','use_birthday','use_phone','pac_number','use_contractend','pac_initialend','coa_group')
            ->join('user','user.use_id','=','use_coach.use_id')
            ->join('pact','pact.use_id','=','user.use_id')
            ->join('coach_group','coach_group.coa_id','=','use_coach.gro_id')
            ->orderBy('use_coach.gro_id','asc')
            ->paginate(2)
            ->toArray();
    }
    /*
     * 作者：*****
     * 内容：根据搜索条件查询信息
     */
    public function searchCoachInfo($search)
    {
        return $this
            ->select('use_name','use_num','use_sex','use_card','use_birthday','use_phone','pac_number','use_contractend','pac_initialend','coa_group')
            ->join('user','user.use_id','=','use_coach.use_id')
            ->join('pact','pact.use_id','=','user.use_id')
            ->join('coach_group','coach_group.coa_id','=','use_coach.gro_id')
            ->where($search)
            ->orderBy('use_coach.gro_id','asc')
            ->paginate(2)
            ->toArray();
    }
}
